package com.srit.system.controller;

import java.util.Iterator;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.srit.system.bean.EffectTime;
import com.srit.system.dao.EffectTimeDao;

@Controller
public class EffectTimeController {
	@Autowired
	private EffectTimeDao effectTimeDao;

	@RequestMapping(value = "/effectTime-saveList", method = RequestMethod.POST)
	public String saveList(EffectTimeListVo effectTimeListVo,
			@RequestParam int groupId) {
		for (Iterator<EffectTime> it = effectTimeListVo.getEffectTimeList()
				.iterator(); it.hasNext();) {
			EffectTime effectTime = it.next();
			effectTimeDao.save(effectTime);
		}
		return "redirect:/effectTimeGroup-edit?id=" + groupId;
	}
}

class EffectTimeListVo {
	private List<EffectTime> effectTimeList;

	public List<EffectTime> getEffectTimeList() {
		return effectTimeList;
	}

	public void setEffectTimeList(List<EffectTime> effectTimeList) {
		this.effectTimeList = effectTimeList;
	}

}